// Copyright (c) 2004 Dmitry Shuklin. All rights reserved.

using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;

namespace Cerebrum.Direct3D.Forms.Docking
{
	/// <summary>
	/// Summary description for Manager.
	/// </summary>
	public class Manager : Cerebrum.Integrator.GenericComponent
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Manager(System.ComponentModel.IContainer container)
		{
			///
			/// Required for Windows.Forms Class Composition Designer support
			///
			container.Add(this);
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
			ConstructComponent();
		}

		public Manager()
		{
			///
			/// Required for Windows.Forms Class Composition Designer support
			///
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
			ConstructComponent();
		}

		private void ConstructComponent()
		{
		m_ManagedControls = new Hashtable();
		}

		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}


		#region Component Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			components = new System.ComponentModel.Container();
		}
		#endregion

		protected System.Collections.Hashtable m_ManagedControls;

		protected Cerebrum.Direct3D.Forms.Control m_Control;

		public Cerebrum.Direct3D.Forms.Control Control
		{
			get
			{
				return m_Control;
			}
			set
			{
				if(m_Control!=value)
				{
					if(m_Control!=null)
					{
						m_Control.ControlAdded -= new ControlEventHandler(m_Control_ControlAdded);
						m_Control.ControlRemoved -= new ControlEventHandler(m_Control_ControlRemoved);
					}
					m_Control = value;
					if(m_Control!=null)
					{
						m_Control.ControlAdded += new ControlEventHandler(m_Control_ControlAdded);
						m_Control.ControlRemoved += new ControlEventHandler(m_Control_ControlRemoved);
					}
				}
			}
		}

		private void m_Control_ControlAdded(object sender, ControlEventArgs e)
		{
			this.m_Control.SuspendLayout();
			this.RefreshLayout();
			this.m_Control.ResumeLayout();
		}

		private void m_Control_ControlRemoved(object sender, ControlEventArgs e)
		{
			this.m_Control.SuspendLayout();
			this.RefreshLayout();
			this.m_Control.ResumeLayout();
		}

		public void RefreshLayout()
		{
		}
	}
}
